package com.fy.distributor.controller;

import com.fy.common.api.CommonResult;
import com.fy.common.util.BeansUtil;
import com.fy.distributor.vo.RecordInputVo;
import com.fy.shop.api.DistributorService;
import com.fy.shop.dto.RecordDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/show")
@Api(tags = "分销商浏览记录")
@RefreshScope
public class DistributorBrowserController {

    @Autowired
    private DistributorService distributorService;


    @ApiOperation(value = "查询浏览记录",response = RecordInputVo.class)
    @GetMapping(value = "/recordFindAll")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "storeId", value = "门店id"),
    })
    public CommonResult recordFindAll(@RequestBody RecordInputVo recordInputVo)
    {
        RecordDto recordDto = new RecordDto();
        BeanUtils.copyProperties(recordInputVo,recordDto);
        List<RecordDto> recordDtoList = distributorService.recordFindAll(recordDto);
        List<RecordInputVo> recordInputVos = BeansUtil.listCopy(recordDtoList,RecordInputVo.class);
        return CommonResult.success(recordInputVos);
    }
}
